<?php
	class User_Check{
		public function checkUserName($username){
			$sql = 'select count(*) as num from zjx_admin_table where `z_username`=\''.$username.'\'';
			$ret = mysql_query($sql);
			$row = mysql_fetch_array($ret);
			
			if($row['num']==1){
				return true;
			}
			return false;
		}
		
		public function checkUserPwd($username,$userpwd){
			$sql = 'select count(*) as num from zjx_admin_table where `z_username`=\''.$username.'\' and `z_userpwd` = \''.md5($userpwd).'\'';
			$ret = mysql_query($sql);
			$row = mysql_fetch_array($ret);
			
			if($row['num']==1){
				return true;
			}
			return false;
		}
		
		public function checkUserLogin(){
			$username = isset($_SESSION['username'])&&!empty($_SESSION['username'])?$_SESSION['username']:null;
			if(!empty($username)){
				return $username;
			}
			$username = isset($_COOKIE['username'])&&!empty($_COOKIE['username'])?$_COOKIE['username']:null;
			if(!empty($username)){
				return $username;
			}
			return false;
		}
	}